<form action="/register" method="post" name="lzform" id="lzform">
  <div id="content">
    <div class="grid-16-8 clearfix">
      <div class="article">

        <div style="padding-left: 50px;">
          <span class="m">
            你的Email地址(强烈建议使用GMail):
          </span>
          <br/>
          <input type="text"  maxlength="60" size="24" name="form_email" value="{{form_email}}" id="email"/>
          <span class="attn hint" id="e_hint" style="display: inline;">
          	{% if is_registered %}
            该Email已经注册过
            {% else %}
            请输入Email地址
            {% endif %}
          </span>
          <br/>
          <div id="e_correct">
            <span class="pl">
              用此邮箱接收确认邮件才能完成注册。
            </span>
          </div>
          <br/>

          <span class="m">
            给自己设一个密码:
          </span>
          <br/>
          <input type="password" value="{{form_password}}" maxlength="20" size="10" name="form_password" id="password"/>
          <span class="attn hint" id="p_hint">
            请输入密码
          </span>
          
          <br/>
          <span class="pl">
            最少4个字符，请使用英文字母（区分大小写）、符号或数字。
          </span>
           <br/><br/>
           <span class="m">
            请再次输入密码
          </span>
          <br/>
           <input type="password" value="{{form_password2}}" maxlength="20" size="10" name="form_password2" id="password2"/>
           {% if pass_not_match %}
			<font color='red'>两次输入的密码不一样</font>
		  {% endif %} 
          <span class="attn hint" id="p_hint2">
            请再次输入密码2
          </span>
          <br/>
          <br/>
          <input type="hidden" value="http://www.douban.com/" name="referer"/>
          <span class="m">
            给自己起一个名号:
          </span>
          <br/>
          <input type="text"  maxlength="15" size="10" name="form_name" value="{{form_name}}" id="name"/>
          <span class="attn hint" id="n_hint">
            请输入你的名号
          </span>
          <br/>
          <span class="pl">
            中、英文均可。
          </span>
          <br/>
          <!--
            <p><img alt="captcha" src="/misc/captcha?id=z41Okb6jO5wQ3w8Q9R523jiP"/><br/><br/><span
            class="pl">请输入上图中的单词</span> <input type="text" name="captcha-solution"/> <input type="hidden"
            value="z41Okb6jO5wQ3w8Q9R523jiP" name="captcha-id"/> </p>
          -->
          <!-- 
          <label>
            <input type="checkbox" name="form_agreement" id="agreement"/>
            我已经认真阅读并同意西门外的《
            <a target="_blank" href="/about?policy=agreement">
              使用协议
            </a>
            》。
          </label>
           -->
           
          <br/>
          <br/>

          <input type="submit" value="我同意西门外《  使用协议  》并完成注册" class="butt" id="button"/>
          <br>
          <br>
          <div>阅读
           <a target="_blank" href="/about?policy=agreement">
              <B>西门外使用协议</B>
            </a>
            </div>
        </div>
        <script type="text/javascript">
          /*<![CDATA[*/
          $("#nav").css("visibility","hidden");
          $("#searbar").css("visibility","hidden");
          var email=$("#email"),e_hint=$("#e_hint"),e_correct=$("#e_correct");
          var passwd=$("#password"),p_hint=$("#p_hint");
          var passwd2=$("#password2"),p_hint2=$("#p_hint2");
          var name=$("#name"),n_hint=$("#n_hint");
          var button=$("#button");
          var email_reg = /^[_\.0-9a-zA-Z+-]+@([0-9a-zA-Z]+[0-9a-zA-Z-]*\.)+[a-zA-Z]{2,4}$/;
          var passwd_reg = /^(\w){4,20}/ ;
          var email_list = new Array('163.com','126.com', '139.com', '188.com', '2008.china.com', '2008.sina.com', '21cn.com', '263.net', 'china.com', 'chinaren.com', 'citiz.net', 'eyou.com', 'foxmail.com', 'gmail.com', 'hongkong.com', 'hotmail.com', 'live.cn', 'live.com', 'mail.china.com', 'msn.com', 'my3ia.sina.com', 'qq.com', 'sina.cn', 'sina.com', 'sina.com.cn', 'sogou.com', 'sohu.com', 'tom.com', 'vip.163.com', 'vip.qq.com', 'vip.sina.com', 'vip.sohu.com', 'vip.tom.com', 'yahoo.cn', 'yahoo.com', 'yahoo.com.cn', 'yahoo.com.hk', 'yahoo.com.tw', 'yeah.net');

          function DPA(s1, s2){
            var m = new Array();
            var i, j;
            for(i=0; i < s1.length + 1; i++) m[i] = new Array(); // i.e. 2-D array

            m[0][0] = 0; // boundary conditions

            for(j=1; j <= s2.length; j++)
            m[0][j] = m[0][j-1]-0 + 1; // boundary conditions

            for(i=1; i <= s1.length; i++)                            // outer loop
            {
              m[i][0] = m[i-1][0]-0 + 1; // boundary conditions

              for(j=1; j <= s2.length; j++)                         // inner loop
              {
                var diag = m[i-1][j-1];
                if( s1.charAt(i-1) != s2.charAt(j-1) ) diag++;

                m[i][j] = Math.min( diag,               // match or change
                Math.min( m[i-1][j]-0 + 1,    // deletion
                m[i][j-1]-0 + 1 ) ) // insertion
                }//for j
                }//for i
                return m[s1.length][s2.length];
              }

              var email_value = '';
              var e_name = '';
              var e_domain = ''
              var e_tip_on = 0;

              function e_back(){
                e_correct.html('<span class="pl">用此邮箱接收确认邮件才能完成注册。</span>');
                passwd.focus();
                e_tip_on = 0;
              }
              function e_set(){
                email.attr('value', e_name + '@' + e_domain);
                e_hint.fadeOut();
                e_back();
              }
              function get_like(s){
                r = 0;
                v = s.split('@');
                domain = v[1];
                e_name = v[0];
                dis = domain.length;
                for (k=0; k < email_list.length; k++){
                  e = email_list[k];
                  d = DPA(domain, e);
                  if (d < dis){
                    dis = d;
                    e_domain = e;
                  }
                }
                if(dis && dis < 4){
                  r = 1;
                }
                return r;
                };

                function check_email(like){
                  e_hint.fadeOut();
                  r = 1;
                  s = email.attr('value');
                  if (!s){
                    r = 0;
                    e_hint.fadeIn();
                  }else if (!email_reg.exec(s)){
                    e_hint.html('请输入正确的Email地址');
                    e_hint.fadeIn();
                    r = 0;
                  }else{
                    if (like && get_like(s)){
                      as = ' <a id="yes_but" href="javascript:void(0)" onclick="e_set()">是</a>／<a href="javascript:void(0)" onclick="e_back()">不是</a>'
                      e_correct.html('<div class="ct"><span class="pl">你是否要输入' + e_name + '@</span>' + e_domain + as + '</div>');
                      $("#yes_but").focus();
                      e_tip_on = 1;
                    }else{
                      e_hint.fadeOut();
                      var url = '/j/register/is_registered?email='+s;
                      $.getJSON(url, function(j){
                     	
                        if (j.ok){
                        
                          e_hint.html('该Email已经注册过');
                          e_hint.fadeIn();
                          email_value = s;
                          r = 0;
                        }
                        else{
                        
                          r = 1;
                        }
                        
                        })
                      }
                    }
                    email_value = email.attr('value');
                    return r
                    };
                    function check_password(){
                      r = 1;
                      if (e_tip_on) return r;
                      s = passwd.attr('value');
                      if (!s){
                        r = 0;
                      }else if(s.length < 4){
                        p_hint.html('最少4个字符');
                        r = 0;
                      }else if (!passwd_reg.exec(s)){
                        p_hint.html('请使用英文字母、符号或数字');
                        r = 0;
                      }
                      if (r){
                        p_hint.fadeOut();
                      }else{
                        p_hint.fadeIn();
                      }
                      return r
                      };
                      
                      
                      function check_passwd_match()
                      {
                      	
                      	s1 = passwd.attr('value');
                      	s2 = passwd2.attr('value');
                      	
                      	if (s1 != s2)
                      	{
                      		p_hint2.html('两次输入密码不一致');
                      		r=0
                      	}
                      	if (r){
                        	p_hint2.fadeOut();
                      	}else{
                        	p_hint2.fadeIn();
                      	}
                      	return r;
                      }
                      
                      
                      function check_name(){
                        r = 1;
                        s = name.attr('value');
                        if (!s){
                          n_hint.fadeIn();
                          r = 0;
                        }else{
                          n_hint.fadeOut();
                        }
                        return r
                        };
                        email.blur(function(){
                          check_email(1);
                          });
                          name.blur(function(){
                            check_name();
                            });
                            passwd.blur(check_password);
                            passwd2.blur(check_passwd_match);
                            
                            button.click(function(){
                              r1 = check_email(0);
                              r2 = check_password();
                              r3 = check_name();
                              r4 = check_passwd_match();
                              if (r1 && r2 && r3 &r4){
                                return;
                              }else{
                                return false;
                              }
                              });
                              /*]]>*/
                            </script>
                          </div>


                          <div class="extra">

                          </div>
                        </div>
                      </div>
                    </form>

